package org.joyflow.core.meta;

import org.joyflow.core.entity.Db;
import org.joyflow.core.instance.DbTypeRegistry;

public class DbMetaCodes {
    public static DbMeta decode(Db db) {
        DbMeta dbMeta = new DbMeta();
        dbMeta.setId(db.getId());
        dbMeta.setName(db.getName());
        dbMeta.setHostname(db.getHostname());
        dbMeta.setPort(db.getPort());
        dbMeta.setDbName(db.getDbName());
        dbMeta.setUsername(db.getUsername());
        dbMeta.setPassword(db.getPassword());
        dbMeta.setDatabaseInterface(DbTypeRegistry.findDatabaseInterface(DbTypeRegistry.instance().getTypeCode(db.getDbTypeId())));
        dbMeta.setDbTypeId(db.getDbTypeId());
        dbMeta.setDbConTypeId(db.getDbConTypeId());
        dbMeta.setDbDirId(db.getDbDirId());
        return dbMeta;
    }
}
